{extend name='main'}

{block name="button"}

{if auth("add_users")}
<button data-modal='{:url("add_users")}' data-title="添加会员" class='layui-btn layui-btn-sm layui-btn-primary'>添加会员</button>
{/if}

{/block}

{block name="content"}

<div class="think-box-shadow">
    {include file='users/index_search'}
    <table class="layui-table margin-top-15" id="userTable" lay-filter="tab" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th lay-data="{type:'checkbox',width:40,fixed:'left'}" class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>
            <th lay-data="{field:'id',width:80,fixed:'left'}" class='text-left nowrap'>UID</th>
            <th lay-data="{field:'addtime',width:200}" class='text-left nowrap'>注册时间</th>
            <th lay-data="{field:'agent',width:120}" class='text-left nowrap'>一级代理</th>
            <th lay-data="{field:'service',width:120}" class='text-left nowrap'>二级代理</th>
            <th lay-data="{field:'tel'}" class='text-left nowrap'>账号</th>
            <th lay-data="{field:'username',width:150}" class='text-left nowrap'>用户名</th>
            <th lay-data="{field:'level',width:80}" class='text-left nowrap'>等级</th>
            <th lay-data="{field:'group_id',width:80}" class='text-left nowrap'>规则组</th>
            <th lay-data="{field:'balance'}" class='text-left nowrap'>账户余额</th>
            <th lay-data="{field:'com'}" class='text-left nowrap'>佣金</th>
            <th lay-data="{field:'tj_com'}" class='text-left nowrap'>下级佣金</th>
            <th lay-data="{field:'all_recharge_num'}" class='text-left nowrap'>累计充值金额</th>
            <th lay-data="{field:'all_recharge_count'}" class='text-left nowrap'>累计充值次数</th>
            <th lay-data="{field:'all_deposit_num'}" class='text-left nowrap'>累计提现金额</th>
            <th lay-data="{field:'all_deposit_count'}" class='text-left nowrap'>累计提现次数</th>
            <th lay-data="{field:'freeze_balance'}" class='text-left nowrap'>冻结金额</th>
            <th lay-data="{field:'lixibao_balance'}" class='text-left nowrap'>利息宝金额</th>
            <th lay-data="{field:'parent_name'}" class='text-left nowrap'>上级用户</th>
            <th lay-data="{field:'invite_code'}" class='text-left nowrap'>邀请码</th>
            <th lay-data="{field:'ip'}" class='text-left nowrap'>最后登录ip</th>
            <th lay-data="{field:'is_jia',width:80}" class='text-left nowrap'>状态</th>
            <th lay-data="{field:'edit',width:280,fixed: 'right'}" class='text-left nowrap'>操作</th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
            <td class='text-left nowrap'>{$vo.id}</td>
            <td class='text-left nowrap'>{$vo.addtime|format_datetime}</td>
            <td class='text-left nowrap'>{$vo.agent}</td>
            <td class='text-left nowrap'>{$vo.service}</td>
            <td class='text-left nowrap'>{$vo.tel}</td>
            <td class='text-left nowrap'>{$vo.username}</td>
            <td class='text-left nowrap'>VIP{$vo.level}</td>
            <td class='text-left nowrap'>{if $vo.group_id}{$groupAllList[$vo.group_id]}{else}-{/if}</td>
            <td class='text-left nowrap'>{$vo.balance}</td>
            <td class='text-left nowrap'>{$vo.com}</td>
            <td class='text-left nowrap'>{$vo.tj_com}</td>
            <td class='text-left nowrap'>{$vo.all_recharge_num}</td>
            <td class='text-left nowrap'>{$vo.all_recharge_count}</td>
            <td class='text-left nowrap'>{$vo.all_deposit_num}</td>
            <td class='text-left nowrap'>{$vo.all_deposit_count}</td>
            <td class='text-left nowrap'>{$vo.freeze_balance}</td>
            <td class='text-left nowrap'>{$vo.lixibao_balance}</td>
            <td class='text-left nowrap'>{$vo.parent_name}</td>
            <td class='text-left nowrap'>{$vo.invite_code}</td>
            <td class='text-left nowrap'>{$vo.ip}</td>
            <td class='text-left nowrap'>
                {if $vo.is_jia>0}
                <a class="layui-btn layui-btn-danger layui-btn-xs">假人</a>
                {else}
                <a class="layui-btn layui-btn-normal layui-btn-xs">真人</a>
                {/if}
            </td>
            <td class='text-left nowrap'>
                {if auth("inyectar/index")}
                <a data-dbclick class="layui-btn layui-btn-xs layui-btn-danger" data-title="打针计划"
                   data-open='{:url("inyectar/index")}?uid={$vo.id}'>打针</a>
                {/if}
                {if auth("usetting/index")}
                <a data-dbclick class="layui-btn layui-btn-xs layui-btn-normal" data-title="做单设置"
                   data-open='{:url("usetting/index")}?uid={$vo.id}'>做单</a>
                {/if}

                {if auth("edit_level")}
                <a data-dbclick class="layui-btn layui-btn-xs layui-btn-danger" data-title="编辑等级"
                   data-modal='{:url("users/edit_level")}?id={$vo.id}'>等级</a>
                {/if}
                {if auth("edit_money")}
                <a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑余额信息"
                   style='background:red;'
                   data-modal='{:url("users/edit_money")}?id={$vo.id}'>余额</a>
                {/if}
                {if auth("edit_users_ankou")}
                <!--<a data-dbclick class="layui-btn layui-btn-xs layui-btn-danger" data-title="暗扣设置"
                   data-modal='{:url("users/edit_users_ankou")}?id={$vo.id}'>暗扣设置</a>-->
                {/if}
                {if auth("edit_users")}
                <a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑用户信息"
                   data-modal='{:url("users/edit_users")}?id={$vo.id}'>编辑</a>
                {/if}
                {if auth("edit_users_bk")}
                <a data-dbclick class="layui-btn layui-btn-xs" data-title="银行卡信息"
                   data-modal='{:url("users/edit_users_bk")}?id={$vo.id}'>银行卡信息</a>
                {/if}
                {if auth("edit_users_address")}
                <a data-dbclick class="layui-btn layui-btn-xs layui-btn-danger" data-title="收货地址信息"
                   data-modal='{:url("users/edit_users_address")}?id={$vo.id}'>地址信息</a>
                {/if}
                {if auth("edit_users_ewm")}
                <!--<a class="layui-btn layui-btn-xs layui-btn"
                   data-action="{:url('edit_users_ewm',['status'=>2,'id'=>$vo.id])}"
                   data-value="id#{$vo.id};status#{$vo.invite_code}" style='background:red;'>刷新二维码</a>-->
                {/if}
                {if auth("tuandui")}
                <a data-dbclick class="layui-btn layui-btn-xs layui-btn-danger" data-title="查看团队" data-reload="true"
                   data-open='{:url("users/tuandui")}?id={$vo.id}'>查看团队</a>
                <a data-dbclick class="layui-btn layui-btn-xs layui-btn-normal" data-title="查看账变" data-reload="true"
                   data-open='{:url("users/caiwu")}?id={$vo.id}'>账变</a>
                {/if}
                {if ($vo.status == 1) and auth("edit_users_status")}
                <a class="layui-btn layui-btn-xs layui-btn-warm"
                   data-action="{:url('edit_users_status',['status'=>2,'id'=>$vo.id])}"
                   data-value="id#{$vo.id};status#2" style='background:red;'>禁用</a>
                {elseif ($vo.status == 2) and auth("edit_users_status") /}
                <a class="layui-btn layui-btn-xs layui-btn-warm"
                   data-action="{:url('edit_users_status',['status'=>1,'id'=>$vo.id])}"
                   data-value="id#{$vo.id};status#1" style='background:green;'>启用</a>
                {/if}
                {if auth("delete_user")}
                <a class="layui-btn layui-btn-xs layui-btn" onClick="del_user({$vo.id})" style='background:red;'>删除</a>
                {/if}
                {if auth("edit_users_status")}
                {if ($vo.is_jia == 1)}
                <a class="layui-btn layui-btn-xs layui-btn-warm"
                   data-action="{:url('edit_users_status2',['status'=>-1,'id'=>$vo.id])}"
                   data-value="id#{$vo.id};status#-1" style='background:red;'>设为真人</a>
                {else/}
                <a class="layui-btn layui-btn-xs layui-btn-warm"
                   data-action="{:url('edit_users_status2',['status'=>1,'id'=>$vo.id])}"
                   data-value="id#{$vo.id};status#1" style='background:green;'>设为假人</a>
                {/if}
                {/if}
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <script>
        function del_user(id) {
            layer.confirm("确认要删除吗，删除后不能恢复", {title: "删除确认"}, function (index) {
                $.ajax({
                    type: 'POST',
                    url: "{:url('delete_user')}",
                    data: {
                        'id': id,
                        '_csrf_': "{:systoken('delete_user')}"
                    },
                    success: function (res) {
                        layer.msg(res.info, {time: 2500});
                        location.reload();
                    }
                });
            }, function () {
            });
        }
    </script>
    <script>
        var table = layui.table;
        //转换静态表格
        var limit = Number('{$Think.get.limit}');
        if (limit == 0) limit = 20;
        table.init('tab', {
            cellMinWidth: 120,
            skin: 'line,row',
            size: 'lg',
            limit: limit
        });
    </script>
    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>
{/block}
